package com.swy.shopgroup;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.View;

import com.swy.shopgroup.adapter.MainViewPagerAdapter;
import com.swy.shopgroup.view.ActsFragment;
import com.swy.shopgroup.view.FoodsFragment;
import com.swy.shopgroup.view.GoodsFragment;
import com.swy.shopgroup.view.Home2Fragment;
import com.swy.shopgroup.view.HomeFragment;
import com.swy.shopgroup.view.MeFragment;
import com.swy.shopgroup.view.MyAcceptFragment;
import com.swy.shopgroup.view.PagesMeFragment;
import com.swy.shopgroup.view.PagesOtherFragment;

import java.util.ArrayList;
import java.util.List;

public class MainActivity2 extends AppCompatActivity {

    private ViewPager viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        List<Fragment> list = new ArrayList<>();
        list.add(new Home2Fragment());
        list.add(new FoodsFragment());
        list.add(new ActsFragment());
        list.add(new MyAcceptFragment());
        list.add(new MeFragment());
        viewPager = findViewById(R.id.mainPager);
        MainViewPagerAdapter mainAdapter = new MainViewPagerAdapter(getSupportFragmentManager(), list);
        viewPager.setAdapter(mainAdapter);
    }

    public void click(View v) {
        switch (v.getId()) {
            case R.id.home:
                viewPager.setCurrentItem(0);
                break;
            case R.id.goods:
                viewPager.setCurrentItem(1);
                break;
            case R.id.mPages:
                viewPager.setCurrentItem(2);
                break;
            case R.id.rPages:
                viewPager.setCurrentItem(3);
                break;
            case R.id.mine:
                viewPager.setCurrentItem(4);
                break;
            default:
                break;
        }
    }
}